package com.sunpy.commonlock.zookeeper;

import org.apache.zookeeper.ZooKeeper;

/**
 * zookeeper实现分布式锁
 *
 * @author sunpeiyu
 * @date 2023-04-10
 */
public interface IZkLockService {

    /**
     * 获取ZooKeeper实例
     * @return
     */
    ZooKeeper getZooKeeperInstance();

    /**
     * 删除指定路径上的节点
     * @param zookeeper
     * @param currentPath
     * @param jobName
     */
    void releaseLock(ZooKeeper zookeeper, String currentPath, String jobName);

    /**
     * 获取锁
     * @param zooKeeper
     * @param pwd
     * @param jobName
     */
    void getLock(ZooKeeper zooKeeper, String pwd, String jobName);

    /**
     * 续期
     * @param zooKeeper
     * @param jobName
     */
    void renewLock(ZooKeeper zooKeeper, String jobName);

}
